<template>
  <p-modal
    :visible="visible"
    :title="title"
    :mask-closable="false"
    :destroy-on-close="true"
    :width="600"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <p-radio-group v-model="value" @change="onChange">
      <p-radio :style="radioStyle" :value="0">
        仅转派PM
      </p-radio>
      <p-radio :style="radioStyle" :value="1">
        仅转派销售
      </p-radio>
      <p-radio :style="radioStyle" :value="2">
        同时转派PM和销售
      </p-radio>
    </p-radio-group>
  </p-modal>
</template>

<script>
import { postleadstransfer, postClueCreate } from '@/api/clue';
export default {
  props: {
    title: {
      type: String,
      default: '线索转派',
    },
    visible: {
      type: Boolean,
      default: false,
    },
    clueId: {
      type: [String, Number],
      default: undefined,
    },
    leadsNo: {
      type: [String, Number],
      default: undefined,
    },
  },

  data() {
    return {
      value: undefined,
      radioStyle: {
        display: 'block',
        height: '30px',
        lineHeight: '30px',
      },
      parentId: '',
    };
  },
  computed: {},
  watch: {
    value() {
      console.log(this.value);
    },
  },
  methods: {
    onChange(e) {},
    handleCancel() {
      this.$emit('update:visible', false);
    },
    async handleOk() {
      const res = await postClueCreate({
        bizModule: 'leads',
        currStatus: '2',
        bizType: '2',
      });
      const processId = res.data.data;
      const result = await postleadstransfer({
        leadsNo: this.leadsNo,
        processId: processId,
        transferObj: this.value,
      });
      if (result?.data?.success) {
        this.$message.success('转派成功');
        this.handleCancel();
        this.$emit('fresh');
      }
    },
  },
};
</script>

<style lang="less" scoped>
/deep/ .poros-form-item {
  margin-bottom: 10px;
}
.item-container {
  display: flex;
  align-items: center;
}
</style>
